<template>
  <div v-if="bannerImg">
    <van-image :src="item.picUrl" v-for="item in bannerImg.bannerList" />

    <div class="cartitem" v-for="item in category2" :key="item.id">
      <h4>{{ item.name }}</h4>
      <van-grid :column-num="3">
        <van-grid-item
          v-for="per in item.categoryList"
          :key="per.id"
          :icon="per.wapBannerUrl"
          :text="per.name"
          @click="goList(bannerImg.id, per.id)"
        />
      </van-grid>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { CategoryGroupList, CurrentCategory } from '@/types/cateList';
import { useRouter } from 'vue-router'
const router = useRouter()
defineProps<{
  category2: CategoryGroupList[]
  bannerImg: CurrentCategory
}>()
const goList = async (id: number, subid: number) => {
  router.push(`list?categoryId=${id}&subCategoryId=${subid}`)
}
</script>

<script lang="ts">
export default {
  name: 'VCatenav'
}
</script>

<style lang="scss" scoped>
* {
  margin: 0;
  padding: 0;
}
.van-image {
  width: 264px;
  height: 96px;
  background: #eee no-repeat 50%;
}
:deep .van-icon__image {
  width: 72px;
  height: 72px;
}
.cartitem h4 {
  padding: 15px 0 10px;
  font-size: 16px;
  border-bottom: 1px solid #d9d9d9;
}
</style>
